# Maintainer: Renato Silva <br.renatosilva@gmail.com>

_realname='winsparkle'
pkgbase="mingw-w64-${_realname}-git"
pkgname=(${MINGW_PACKAGE_PREFIX}-${_realname}-git)
provides=(${MINGW_PACKAGE_PREFIX}-${_realname})
conflicts=(${MINGW_PACKAGE_PREFIX}-${_realname})
pkgver=r332.7c208b2
pkgrel=1
url='https://winsparkle.org/'
pkgdesc='App update framework for Windows, inspired by Sparkle for OS X (mingw-w64)'
license=('MIT')
arch=('any')
depends=(${MINGW_PACKAGE_PREFIX}-gcc-libs ${MINGW_PACKAGE_PREFIX}-expat ${MINGW_PACKAGE_PREFIX}-wxWidgets)
makedepends=(${MINGW_PACKAGE_PREFIX}-gcc)
source=(${_realname}::'git+https://github.com/vslavik/winsparkle'
        001-compile-fixes.patch
        Makefile)
sha256sums=('SKIP'
            '0c36fcd5e3cc7f05b678fbc612fe3ac85a4f0234e7b131ff721f317bffcd719c'
            'c92047c7b4ed2829583f967b279d8d771e268f5cf204cf7c4808681132bc5786')

consolidate() {
  cp ../Makefile src
}

prepare() {
  cd "${srcdir}/${_realname}"
  consolidate
  patch -p1 < "${srcdir}"/001-compile-fixes.patch
}

pkgver() {
  cd "${srcdir}/${_realname}"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
  cd "${srcdir}/${_realname}/src"
  make
}

package() {
  cd "${srcdir}/${_realname}"
  install -D -m644 include/winsparkle.h         "${pkgdir}${MINGW_PREFIX}/include/winsparkle.h"
  install -D -m644 include/winsparkle-version.h "${pkgdir}${MINGW_PREFIX}/include/winsparkle-version.h"
  install -D -m644 src/libwinsparkle.a          "${pkgdir}${MINGW_PREFIX}/lib/libwinsparkle.a"
  install -D -m644 src/libwinsparkle.dll.a      "${pkgdir}${MINGW_PREFIX}/lib/libwinsparkle.dll.a"
  install -D -m755 src/libwinsparkle.dll        "${pkgdir}${MINGW_PREFIX}/bin/libwinsparkle.dll"
  install -D -m644 COPYING                      "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
